#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for (int i = l; i <= r; ++i)
typedef double db; 
const int N = 5e5 + 5;
const db inf = 1e6, eps = 1e-6; 
int n, T, a[N], q[N]; db p[N], ans;   

int main () {
  freopen ("I.in", "r", stdin); 
  freopen ("I.out", "w", stdout); 
  scanf("%d", &T); 
  while (T--) {
    scanf("%d", &n);   
    rep(i, 1, n) scanf("%d", &a[i]), ++a[i];
    rep(i, 1, n) scanf("%d", &q[i]), p[i] = 1.0 * q[i] / 1e5;
    ans = n; 
    rep(i, 1, n) 
      ans = min(ans, i - 1 + ((1.0 - p[i]) * (i - a[i]) + 1) / p[i]); 
    printf("%.15lf\n", ans); 
  }
  return 0; 
}